package poker;

import java.util.Scanner;
class Human extends Player 
{
    private static final int MAX_CHANGES = 4;
    private static final int HAND_SIZE = 5;
	
	Human(String name) 
	{
		super(name);
	}

	public int[] picks() 
	{
		Scanner s = new Scanner(System.in);
		String input = "";
		int changes;
		System.out.println("When you are ready press 'r'");
		while (!input.equals("r")) 
		{
			input = s.next();
		}
		//wyswietlanie kart w rece
		System.out.println("Your cards: " + "\n" + getHand().toString());
		//wyswietlanie ilosci zetonow
		System.out.println("Chips: " + getChips());
		//ile kart do wymiany
		System.out.println("How many cards you want to exchange? 0-4");
		changes = s.nextInt();
		while(changes < 0 || changes > MAX_CHANGES) 
		{
			System.out.println("Choose between 0-4");
			changes = s.nextInt();
		}
		int[] result = new int[changes];
		if (changes == 0) 
		{
			return result;
		}
		int current;
		//karty do wymiany
		System.out.println("Now pick " + Integer.toString(changes) + " distinct numbers from 1-5");
		for (int i = 0; i < changes; i++) 
		{
			current = s.nextInt();
			current--;
			while(current < 0 || current > HAND_SIZE - 1 || find(current, result, i)) 
			{
				System.out.println("You have already chosen that number!");
				current = s.nextInt();
			}
			result[i] = current;
		}
		return result;
	}
	
	public String buyIn()
	{
		System.out.println("Your chips: " + getChips());
		System.out.println("Chose action: buyin | quit");
		Scanner scan = new Scanner(System.in);
		String action = scan.next();
		return action;
	}
	public String action(int currBid, boolean allIn)
	{
		System.out.println(getName());
		//if(getHand().size() > 0)
		if(getHand() != null)
		{
			System.out.println("Your cards: " + "\n" + getHand().toString());
		}
		System.out.println("Current bid: " + currBid + " | Your bid: " + getBid() + " | Your chips: " + getChips());
		System.out.println("Chose one: check|bet|raise|call|fold|all-in|quit");
		Scanner scanner = new Scanner(System.in);
		String act = scanner.next();
		return act;		
	}
	public int bet()
	{
		System.out.println("How much you want to bet?");
		int bet = 0;
		Scanner scan = new Scanner(System.in);
		while(bet<1)
		{			
			bet = scan.nextInt();
			if(bet<1)
			{
				System.out.println("Must be 1 or higher");
			}
		}
		return bet;
	}
	public int raise()
	{
		System.out.println("By how much you want to raise your bid?");
		int raise = 0;
		Scanner scann = new Scanner(System.in);
		while(raise<1)
		{			
			raise = scann.nextInt();
			if(raise<1)
			{
				System.out.println("Must be 1 or higher");
			}
		}
		return raise;
	}
}